package com.authine.cloudpivot.ext.service;

import com.alibaba.cola.dto.SingleResponse;
import com.authine.cloudpivot.ext.dto.OrderCustomerDto;
import com.authine.cloudpivot.ext.dto.OrderTraceDto;
import com.authine.cloudpivot.ext.dto.api.AgreeRefundVO;
import com.authine.cloudpivot.ext.dto.api.BulkRefundVO;
import com.authine.cloudpivot.ext.enums.order.OrderApproveStatusEnum;
import com.authine.cloudpivot.ext.vo.CustomerOrderVo;
import com.authine.cloudpivot.ext.vo.TempOrderReceiptVo;
import com.authine.cloudpivot.ext.vo.i.IOrderCustomerVO;
import com.authine.cloudpivot.ext.vo.i.IOrderVendorVO;
import com.authine.mvp.app.launcher.domain.SelectorFormat;
import com.authine.mvp.app.launcher.dto.bo.response.BO;

import java.math.BigDecimal;
import java.util.Collection;
import java.util.List;
import java.util.Map;

/**
 * 订单服务接口
 */

public interface OrderService {
    /**
     * 采购订单-批量修改客户订单状态（批量取消/批量付款/提交审批）
     *
     * @param dto
     */
    SingleResponse batchUpdateOrderCustomer(OrderCustomerDto dto) throws RuntimeException;

    /**
     * 接单
     * cn/gomro/core/bizes/order/service/impl/OrdersService.orderTaking
     *
     * @param vendorOrderIds 供应商订单编号
     * @return
     * @throws
     */
    boolean orderTaking(List<String> vendorOrderIds) throws RuntimeException;

    /**
     * 供应商发货
     *
     * @param dto
     * @return
     * @throws
     */
    SingleResponse<BO> vendorDeliveryLogistics(OrderTraceDto dto) throws RuntimeException;

    /**
     * 分批收货
     *
     * @param orderGoodsId,num
     * @return
     * @throws
     */
    Boolean goodsReceipt(String orderGoodsId, BigDecimal num) throws RuntimeException;

    /**
     * 批量收货
     *
     * @param orderCustomerGoodIds
     * @return
     * @throws
     */
    TempOrderReceiptVo goodsReceiptBatch(List<String> orderCustomerGoodIds) throws RuntimeException;

    /**
     * 客户申请退款
     *
     * @param bulkRefundVO
     * @return
     * @throws
     */
    List<Map<String, Object>> applyRefund(List<BulkRefundVO> bulkRefundVO) throws RuntimeException;

    /**
     * 获取供应商/客户订单商品通过客户/供应商订单商品ID
     * @param orderCustomerGoodsId
     * @param orderVendorGoodsId
     * @return
     */
    Map<String, Object> getOrderGoods(String orderCustomerGoodsId, String orderVendorGoodsId);

    /**
     * 审批退款申请
     *
     * @param agreeRefundVO
     * @return
     * @throws
     */
    SingleResponse approvalRefund(AgreeRefundVO agreeRefundVO) throws RuntimeException;


    /**
     * 修改供应商订单、客户订单状态、供应商商品和客户商品状态(同一个订单下)
     *
     * @param customerOrderIds
     * @return
     * @throws
     */
    void updateOrderStatus(List<String> customerOrderIds);

    /**
     * 财务确认收供应商退款
     *
     * @param orderGoodsReturnsIds
     * @return
     * @throws
     */
    boolean refundFinanceConfirm(List<String> orderGoodsReturnsIds);

    /**
     * 确认到货
     * cn/gomro/core/bizes/order/service/impl/OrdersService.confireReturn
     *
     * @param orderVendorGoodsIds 供应商订单商品ID
     * @return
     */
    SingleResponse<BO> confireReturn(List<String> orderVendorGoodsIds);

    /**
     * 客户退货(客户订单详情-提交退货物流)
     * cn/gomro/core/bizes/order/service/impl/OrdersService.goodsReturn
     *
     * @param orderCustomerGoodsIds
     * @param logistics
     * @param waybill
     * @return
     */
    Map<String,List<String>> goodsReturn(List<String> orderCustomerGoodsIds, String logistics, String waybill);

    /**
     * 判断当前供应商是否为虚拟供应商
     *
     * @return
     */
    boolean isVirtual(SelectorFormat dept);

    /**
     * 通过商品ID获取报价商品信息
     *
     * @return
     */
    Map<String, Object> getQuotationGoods(String goodsId);

    /**
     * 平台修改退款单
     * @param refundId
     * @param amount
     * @param num
     * @param memo
     * @return
     */
    SingleResponse<BO> editRefund(String refundId, BigDecimal amount, BigDecimal num, String memo);

    /**
     * 根据商品修改订单状态
     * @param customerOrderIds
     */
    void updateTransferOrderStatus(Collection<String> customerOrderIds);

    /**
     * 根据消耗创建订单(订单中心-寄售消耗统计-消耗待结算明细-生成订单)
     *
     * @param idList
     * @return
     */
    SingleResponse buildVmiOrder(List<String> idList);

    /**
     * 客户订单提交前置条件
     *
     * @param data
     * @return
     */
    SingleResponse orderBeforCondition(Map<String, Object> data);

    /**
     * 客户订单提交（购物车下单）
     *
     * @param orderCustomer
     * @return
     */
    SingleResponse submitOrder(Map<String, Object> orderCustomer);

    /**
     * 生成订单结果，如果为虚拟供应商，添加至转采客户订单、转采客户订单商品表中
     * 普通订单-》转采订单
     *
     * @param orderCustomerId
     * @return
     */
    void toTransferOrder(String orderCustomerId);

    /**
     * 接受vo创建订单（第三方系统创建订单）
     * cn/gomro/core/bizes/order/service/IOrdersService.createOrder(OrderVo order)
     *
     * @return
     */
    IOrderCustomerVO iCreateOrder(CustomerOrderVo orderVo);


    /**
     * 判断供应商组织是否是小规模纳税人，
     * 重新计算供应商订单商品及订单金额（供第三方系统创建订单使用）
     */
    void calculateOrder(IOrderCustomerVO orderCustomer);

    /**
     * 判断供应商组织是否是小规模纳税人，
     * 重新计算供应商订单商品及订单金额（供第三方系统创建订单使用）
     */
    void calculateOrderMap(final Map<String, Object> orderCustomer);
    /**
     * 退款审批修改商品表label状态
     * @param orderCustomerGoodsId 客户订单商品id
     * @param orderVendorGoodsId   供应商订单商品id
     * @param label  label枚举
     * @return {@link SingleResponse< BO>}
     * @throws
     * @author zhanjh
     * @date 2021/11/4 14:26
     */
    SingleResponse editOrderLabel(String orderCustomerGoodsId, String orderVendorGoodsId, OrderApproveStatusEnum label);
}
